<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function maxr(charstr) {
            var i = 0;
            var j = 1;
            var maxlength = 0;
            var maxchar = "";
            while (i < charstr.length) {
                if (charstr.charAt(i) == charstr.charAt(j)) {
                    j++;
                } else {
                    if (j - i > maxlength) {
                        maxlength = j - i;
                        maxchar = charstr.charAt(i);
                    }
                    i = j;
                    j++;
                }
            }
            var char = ""
            for (var k = 0; k < maxlength; k++) {
                char += maxchar
            }
            return char;

        }
        console.log(maxr("mmmiijjjjkkkkkkssptr")); 
    </script>
</head>

<body>

</body>

</html>